package com.kaibes.platform.article.util;

import java.math.BigInteger;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.kaibes.orm.core.core.Page;
import com.kaibes.platform.article.db.entity.ArticleComment;
import com.kaibes.platform.article.db.service.ArticleCommentService;
import com.kaibes.web.util.WebUtils;

@Component
public class CommentUtils {

    @Autowired
    private ArticleCommentService articleCommentService;
    
    public long count() {
        return articleCommentService.count();
    }
    
    public Page<ArticleComment> page() {
        HttpServletRequest request = WebUtils.getRequest();
        BigInteger articleId = (BigInteger) request.getAttribute("articleId");
        int commentPage = (int) request.getAttribute("commentPage");
        return articleCommentService.pageDescAllByArticleId(commentPage, 10, articleId);
    }
    
    public ArticleComment getById(BigInteger id) {
        return articleCommentService.getById(id);
    }
    
}
